﻿using Core.Reader;
using Core.Writer;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Core.Tools
{
    public static class RWHelper
    {
        public static void Copy(IDataReader Reader, IDataWriter Writer)
        {
            Writer.ObjectType = Reader.ObjectType;

            if (Reader.ObjectType == Enums.RWTypes.Array)
            {
                Reader.Read();
                Writer.Next();

                for (int i = 0; i < Reader.Count; i++)
                {
                    Writer[i] = Reader[i];
                }
            }
            else
            {
                while (Reader.Read())
                {
                    Writer.Next();

                    foreach (var Item in Reader.Fields)
                    {
                        Writer[Item] = Reader[Item];
                    }
                }
            }
        }
    }
}
